<cfsilent><!---

CF_Kalendar

COPYRIGHT & LICENSING INFO
-------------------------------------------------------------------

Copyright 2006 TJ Downes - tdownes@sanative.net - http://www.sanative.net

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

--->
<!--- attributes.calendarLinkPage - the page that the user is taken to when they click an event --->
<cfparam name="Attributes.calendarLinkPage" type="string" default="" />
<!--- attributes.ExcludeTimeHeader - boolean to specifiy if the header on the calendar for times is displayed --->
<cfparam name="Attributes.ExcludeTimeHeader" type="boolean" default="no" />
<!--- attributes.KalendarRequest  contains the request based data and rules for Kalendar. --->
<cfparam name="Attributes.KalendarRequest" type="any" />
<!--- attributes.urlAddString - a URL string to add to the calendarLinkPage attribute --->
<cfparam name="Attributes.urlAddString" type="string" default="" />
<!--- attributes.view - defines which display mode to show: day, week, weeklist, month, condensed --->
<cfparam name="Attributes.view" type="string" default="list" />

<!--- Config --->
<cfscript>
	EventRecords = attributes.KalendarRequest.getReturnedEvents(session.user,request.timezones);
	KalendarConfig = attributes.KalendarRequest.getKalendarConfig();
	FirstDateOfWeek = attributes.KalendarRequest.getFirstDisplayDateOfMonth();
	optionBarVars.view = attributes.view;
	optionBarVars.KalendarRequest = attributes.KalendarRequest;
</cfscript>

</cfsilent>

<cfmodule template="OptionBar.cfm" attributecollection="#optionBarVars#">

<cfoutput>
<table id="mc">
<tr>
	<td colspan="7" id="mcNav">
	<!--- menu to navigate forward and backward, month name and year --->
	<ul>
		<li class="first"><a title="#DateFormat(DateAdd("m", -1, attributes.KalendarRequest.getLinkDate()), "mmmm yyyy")#" href="#cgi.SCRIPT_NAME#?linkDate=#DateFormat(DateAdd("m", -1, attributes.KalendarRequest.getLinkDate()), "mm/dd/yyyy")#&amp;view=list&amp;categoryID=#attributes.KalendarRequest.getCategoryID()#" title="#DateFormat(DateAdd("m", -1, attributes.KalendarRequest.getLinkDate()), "mmm yyyy")#">&##171;</a></li>
		<li>#DateFormat(attributes.KalendarRequest.getLinkDate(), "mmmm yyyy")#</li>
		<li class="last"><a title="#DateFormat(DateAdd("m", 1, attributes.KalendarRequest.getLinkDate()), "mmmm yyyy")#" href="#cgi.SCRIPT_NAME#?linkDate=#DateFormat(DateAdd("m", 1, attributes.KalendarRequest.getLinkDate()), "mm/dd/yyyy")#&amp;view=list&amp;categoryID=#attributes.KalendarRequest.getCategoryID()#" title="#DateFormat(DateAdd("m", 1, attributes.KalendarRequest.getLinkDate()), "mmm yyyy")#&categoryID=#attributes.KalendarRequest.getCategoryID()#">&##187;</a></li>
	</ul>
	</td>
</tr>
<tr>
	<!--- generate day names --->
	<cfloop from="1" to="7" index="i">
	<td class="eventDayName"><cfoutput>#left(dayOfWeekAsString(i), 2)#</cfoutput></td>
	</cfloop>
</tr>
</cfoutput>
<!--- loop to create days, then loop over array to see if it has events --->
<cfloop index="LoopWeek" from="#attributes.KalendarRequest.getFirstWeekOfMonth()#" to="#attributes.KalendarRequest.getLastWeekOfMonth()#">
<tr>
	<cfloop index="LoopIndex" from="0" to="6">
	<cfset EventExists = 0 />
	<cfsilent>
	<cfloop index="i" from="1" to="#ArrayLen(EventRecords)#">
		<cfif CreateODBCDate(eventRecords[i].StartDate) lte CreateODBCDate(DateAdd('d', LoopIndex, FirstDateOfWeek))>
			<cfif CreateODBCDate(eventRecords[i].EndDate) gte CreateODBCDate(DateAdd('d', LoopIndex, FirstDateOfWeek))>
				<cfset EventExists = 1 />
			</cfif>
		</cfif>
	</cfloop>
	</cfsilent>
	<td class="eventDayHeader<cfif EventExists> mcEvent</cfif>">
	<cfoutput>
	<cfset thisDay = DateAdd('d', LoopIndex, FirstDateOfWeek) />
	<cfif Month(DateAdd('d', LoopIndex, FirstDateOfWeek)) eq Month(attributes.KalendarRequest.getLinkDate())><cfif EventExists>#Day(thisDay)#<cfelse>#Day(DateAdd('d', LoopIndex, FirstDateOfWeek))#</cfif></cfif></cfoutput></td>
	</cfloop>
</tr>
<cfset FirstDateOfWeek = CreateODBCDate(DateAdd('d', 7, FirstDateOfWeek)) />
</cfloop>
</table>

<!--- the list of events --->
<div id="condensedListEvents">
<cfif ArrayLen(EventRecords) neq 0>
<cfloop index="i" from="1" to="#ArrayLen(EventRecords)#">
<cfif Month(eventRecords[i].StartDate) eq Month(attributes.KalendarRequest.getLinkDate()) OR Month(eventRecords[i].EndDate) eq Month(attributes.KalendarRequest.getLinkDate())>
<cfoutput>
	<div class="eventitemtitles" style="<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryBGColor))>background-color: ###eventRecords[i].CategoryBGColor#;</cfif><cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))>color: ###eventRecords[i].CategoryTextColor#;</cfif>">
		#DateFormat(eventRecords[i].StartDate, "mmm dd")#<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate> - #DateFormat(eventRecords[i].EndDate, "mmm dd")#</cfif>: #eventRecords[i].Title#
	</div>
	<div class="eventDisplay"<cfif len(trim(eventRecords[i].Teaser)) OR len(trim(eventRecords[i].Description))> title="#Attributes.ToolTipFormatter.eventTitleTip(eventRecords[i].StartDate, eventRecords[i].EndDate, Trim(eventRecords[i].Title), KalendarConfig.getToolTipSubLength())#|#Attributes.ToolTipFormatter.eventBodyTip(eventRecords[i].Teaser, eventRecords[i].Description, KalendarConfig.getMaxDescriptionSize())#"</cfif><cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryBGColor))> style="background-color: ###eventRecords[i].CategoryBGColor#;"</cfif>>
		<a title="#Trim(eventRecords[i].Title)#" href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(attributes.KalendarRequest.getLinkDate())#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>&KeepThis=true&TB_iframe=true&height=400&width=450" class="thickbox"<cfif KalendarConfig.getUseCategoryColors() AND Len(Trim(eventRecords[i].CategoryTextColor))> style="color: ###eventRecords[i].CategoryTextColor#;"</cfif>>#Trim(eventRecords[i].Title)#</a>
	</div>

	<div style="display:none;" class="vevent">
		<span class="dtstamp">#DateFormat(Now(), "yyyy-mm-dd")#T#TimeFormat(Now(), "HH:mm:ss")#</span>
		<span class="summary title">#Trim(eventRecords[i].Title)#</span>
		<a href="#attributes.calendarLinkPage#?#eventRecords[i].EventIDLabel#=#eventRecords[i].EventID#&amp;View=#attributes.View#&amp;linkDate=#UrlEncodedFormat(attributes.KalendarRequest.getLinkDate())#<cfif len(attributes.urlAddString)>#attributes.urlAddString#</cfif>" class="url">Event Link</a>
		<div class="description">#eventRecords[i].Description#</div>
		<span class="dtstart" title="#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#T#TimeFormat(eventRecords[i].StartDate, "HH:mm:ss")#">#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#T#TimeFormat(eventRecords[i].StartDate, "HH:mm:ss")#</span>
		<cfif eventRecords[i].StartDate neq eventRecords[i].EndDate><span class="dtend" title="<cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif>T#TimeFormat(eventRecords[i].EndDate, "HH:mm:ss")#"><cfif eventRecords[i].EndDate neq eventRecords[i].StartDate>#DateFormat(eventRecords[i].EndDate, "yyyy-mm-dd")#<cfelse>#DateFormat(eventRecords[i].StartDate, "yyyy-mm-dd")#</cfif>T#TimeFormat(eventRecords[i].EndDate, "HH:mm:ss")#</span></cfif>
	</div>
</cfoutput>
</cfif>
</cfloop>
</cfif>
</div>